var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/cmd/eslint.ts
var eslint_exports = {};
__export(eslint_exports, {
  default: () => eslint_default,
  eslint: () => eslint
});
module.exports = __toCommonJS(eslint_exports);
var import_eslint = require("eslint");
var eslint = async ({
  cwd,
  fix = true,
  extensions = [".js", ".jsx", ".ts", ".tsx"],
  files = ["src"]
}) => {
  try {
    const linter = new import_eslint.ESLint({
      cwd,
      fix,
      extensions
    });
    const results = await linter.lintFiles(files);
    const formatter = await linter.loadFormatter();
    const output = formatter.format(results);
    if (output) {
      console.log(output);
      process.exitCode = 1;
    }
  } catch (err) {
    process.exitCode = 1;
  }
};
var eslint_default = (api) => {
  api.registerCommand({
    name: "eslint",
    description: "find and fix problems in your JavaScript code by eslint",
    details: `
$ umi eslint [files] --fix --ext .ts,.tsx --cache

* files \u5F85\u6821\u9A8C\u7684\u6587\u4EF6\u5939\u6216\u6587\u4EF6\u5217\u8868\uFF0C\u9ED8\u8BA4 ["src"]
* fix \u662F\u5426\u81EA\u52A8\u4FEE\u590D\u6587\u4EF6\uFF0C\u9ED8\u8BA4 true
* ext \u5F85\u6821\u9A8C\u6587\u4EF6\u7684\u6269\u5C55\u540D\uFF0C\u9ED8\u8BA4 .js,.jsx,.ts,.tsx
* cache \u662F\u5426\u7F13\u5B58\u6821\u9A8C\u7ED3\u679C\uFF0C\u4E0B\u6B21\u6821\u9A8C\u65F6\u57FA\u4E8E\u7F13\u5B58\u7ED3\u679C\uFF0C\u9ED8\u8BA4 false
    `,
    async fn({ args }) {
      try {
        const { cwd } = api.paths;
        const { _: files, fix, extensions } = args;
        await eslint({ cwd, fix, extensions, files });
      } catch (err) {
        console.log(err);
        process.exitCode = 1;
      }
    }
  });
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  eslint
});
